package ch.usi.inf.pf2.cell;
import java.util.HashMap;

import ch.usi.inf.pf2.cell.Converter;
import junit.framework.TestCase;

/**
 * 
 * @author Yotam Sharon
 *
 */

public class TestConverter extends TestCase {

	/**
	 * Test fillLetters() method
	 */
	public void testfillLetters() {
		Converter converter = new Converter();
		converter.setCellReference("AB1");
		HashMap<Character, Integer> letters = converter.getLetters();
		assertEquals(true,1 == letters.get('A'));
	}
	
	/**
	 * test cellLetters() method
	 */
	public void testCellLetters() {
		Converter converter = new Converter();
		converter.setCellReference("AB12");
		assertEquals("AB", converter.getCellLetters());
	}
	
	/**
	 * test convertToNumbers() method and setCellReference() method
	 */
	public void testConvertToNumbers() {
		Converter converter = new Converter();
		converter.setCellReference("BCB12");
		converter.convertToNumbers();
		assertEquals(12, converter.getCellReferenceNumbers()[1]);
		assertEquals(1432, converter.getCellReferenceNumbers()[0]);
		converter.setCellReference("AA1");
		converter.convertToNumbers();
		assertEquals(27, converter.getCellReferenceNumbers()[0]);
		assertEquals(1, converter.getCellReferenceNumbers()[1]);
		converter.setCellReference("ZZ1");
		converter.convertToNumbers();
		assertEquals(702, converter.getCellReferenceNumbers()[0]);
		assertEquals(1, converter.getCellReferenceNumbers()[1]);
	}
	
	public void testConvertToString() {
		Converter converter = new Converter();
		converter.setCellReferenceNumbers(new int[]{1432,94});
		converter.convertToString();
		assertEquals("BCB94", converter.getCellReference());
		converter.setCellReferenceNumbers(new int[] {702,1});
		converter.convertToString();
		assertEquals("ZZ1", converter.getCellReference());
		
	}
}
